package main

func NewWants() (wants []Want) {
	SqliteDB().Find(&wants)

	for i := 0; i < len(wants); i++ {
		SqliteDB().Where("want_id = ?", wants[i].ID).Find(&wants[i].Answers)
	}
	return
}

func CreateWant(want Want) (err error) {
	err = SqliteDB().Create(&want).Error
	if err != nil {
		return
	}

	return
}

func DeleteWans(want Want) (err error) {
	err = SqliteDB().Delete(&want).Error
	if err != nil {
		return
	}

	return SqliteDB().Where("want_id = ?", want.ID).Delete(&want.Answers).Error
}
